<template>
    <div id="seller">
        <div class="fa fa-chevron-left" id="back" @click="backClick"></div>
        <div id="login-title">卖家注册</div>

        <input type="text" placeholder="店铺名称：3-15个字符" v-model="nameOfShop" >
        <input type="text" placeholder="描述下你的店铺:5-50个字符" v-model="nameDesp">
        <br>
        <button @click="sellerClick" :disabled="isNull" :class="{'background':isNull}">点击注册</button>
        <router-link to="/" id="p">回到首页</router-link>
        <div v-if="sellerThen">{{sellerThen}}</div>
        <div>{{judgeNull}}</div>
    </div>
</template>

<script>

export default {
    
 data:function(){
        return {
            isNull:true,
            nameOfShop:"",
            nameDesp:""

        }

    },
    methods:{
        backClick:function(){
            history.back();
        }, 
        sellerClick:function(){
            var data = {
                nameOfShop:this.nameOfShop,
                nameDesp:this.nameDesp,
            };
            this.$store.dispatch("requestSeller",data);
        },
    },
    computed: {
        judgeNull:function(){
            var reg = /^[A-Za-z0-9\u4e00-\u9fa5_]{3,15}$/;
            var reg1 = /^[A-Za-z0-9\u4e00-\u9fa5_]{5,50}$/;
            if(!reg.test(this.nameOfShop)){
                this.isNull = true;
            }else  if(!reg1.test(this.nameDesp)){
                this.isNull = true;
            }else{
                this.isNull = false;
            }
        },
        sellerThen:function(){
            return this.$store.state.sellerThen;
        }
    }
}
</script>

<style scoped>
     #seller{
    background-color: #cccccc;
    height: 100vh;
}
#login-title{
    text-align: center;
    font-size: 15px;
    height: 45px;
    line-height: 45px;
    background-color: skyblue;
    font-family: 宋体;
    font-weight: 700;
}
#back{
    position: absolute;
    height: 4px;
    line-height: 45px;
    left: 15px;
}
#seller input{
height: 45px;
width: 95%;
margin-left: 8px;
margin-top: 10px;
padding: 10px;
}
button{
    height: 45px;
    width: 95%;
    margin-left: 8px;
    margin-top: 10px;
    padding: 10px;
    background-color: deepskyblue;
    border-radius: 5px;
}
.background{
    background-color: #999999;
}
#p{
    width: 100%;
    color: rebeccapurple;
    margin-left: 35%;
     margin-right: 50%;

}
</style>